/**
 * 
 */
package id.ac.gunadarma.paracorp.model;

import java.io.Serializable;

import org.springframework.data.annotation.Transient;

/**
 * @author rezalesmana
 *
 */
public class TranslationReference implements Serializable {
	
	private static final long serialVersionUID = 8959863806587034764L;

	private String translationReferenceId;

	private String language;

	public String getTranslationReferenceId() {
		return translationReferenceId;
	}

	public void setTranslationReferenceId(String translationReferenceId) {
		this.translationReferenceId = translationReferenceId;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}
	
	public static TranslationReference convert(TranslatedSentence translatedSentence) {
		TranslationReference reference = null;
		
		if(translatedSentence.getId() != null) {
			reference = new TranslationReference();
			reference.setLanguage(translatedSentence.getLanguage());
			reference.setTranslationReferenceId(translatedSentence.getId());
		}
		
		return reference;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((language == null) ? 0 : language.hashCode());
		result = prime
				* result
				+ ((translationReferenceId == null) ? 0
						: translationReferenceId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TranslationReference other = (TranslationReference) obj;
		if (language == null) {
			if (other.language != null)
				return false;
		} else if (!language.equals(other.language))
			return false;
		if (translationReferenceId == null) {
			if (other.translationReferenceId != null)
				return false;
		} else if (!translationReferenceId.equals(other.translationReferenceId))
			return false;
		return true;
	}

}
